﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;

using EHTWebsite.Code;
using EHTWebsiteProject.Code.BLL;
using System.Resources;
using System.Threading;
using System.Globalization;
using System.Text;
using Telerik.Web.UI;
using System.Collections.Generic;
using EHTWebsiteProject.Code.Entity;

namespace EHTWebsiteProject.Administrator
{
    public partial class EHTConfigProduct : System.Web.UI.Page
    {
        public Boolean IsVN = true;
        private String Loai = "";
        private String languageCode = "vi-VN";        
        private ResourceManager rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {
                    languageCode = Session[HangSo.LANGUAGE_CODE].ToString();
                    if (languageCode == "en-us")
                    {
                        IsVN = false;
                    }

                }
                catch (Exception ex)
                {
                }

                Thread.CurrentThread.CurrentCulture = new CultureInfo(languageCode);
                LoadLanguage(Thread.CurrentThread.CurrentCulture);
            }
        }

        /// <summary>
        /// Ham load ngon ngu
        /// </summary>
        /// <param name="ci"></param>
        public void LoadLanguage(CultureInfo ci)
        {
            lbSave.Text = rm.GetString("lbSave", ci);
            lbBack.Text = rm.GetString("lbBack", ci);
            lbConfig.Text = rm.GetString("lbConfig",ci);
        }

        /// <summary>
        /// Ham lay cac tham so
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public ParaProducts GetParaProducts(ParaProducts theParaProducts)
        {                       
                theParaProducts.ShowArticle = rbArticle_Show.Checked.ToString();           
                theParaProducts.ShowNavigation = rbNavigation_Show.Checked.ToString();
            
                theParaProducts.NumIntro = 1;
           

           
                theParaProducts.Columns = 1;
                 
                theParaProducts.DisplayImg = rbImage_Show.Checked.ToString();            
                theParaProducts.DisplayPrice = rbPrice_Yes.Checked.ToString();                       
                theParaProducts.DisplayThumbnail = rbThumbnail_Yes.Checked.ToString();                       
                theParaProducts.ShowRelation = rbRelation_Yes.Checked.ToString();            

            theParaProducts.WithThumb = txtWidthThumb.Text;                       

            return theParaProducts;
        }

        protected void imgSave_Click(object sender, ImageClickEventArgs e)
        {
            // lấy giá trị trên sesion  gán vào mảng
            ArrayList arr = (ArrayList)Session["ArrayListConfig"];
            for (int i = 0; i < arr.Count; i++)
            {
                ParaProducts theParaProducts = new ParaProducts();
                ParaProducts theProducts = new ParaProducts();
                theParaProducts = GetParaProducts(theProducts);
                theParaProducts.ParaProductsID = Int32.Parse(arr[i].ToString());
                ThamSoProvider.UpdateParaProducts(theParaProducts);                
            }

            Response.Redirect("EHTProducts.aspx");
        }
    }
}